package visiopuce.DAO;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import org.hibernate.ObjectNotFoundException;
import org.hibernate.Query;

import visiopuce.HibernateUtil;
import visiopuce.objets.VerifFish;

public class VerifFishDAOImpl extends GenericDAOImpl<VerifFish, BigDecimal> implements VerifFishDAO {

	/** Constructeur priv� */
	private VerifFishDAOImpl() {
	}

	/** Instance unique non pr�initialis�e */
	private static VerifFishDAOImpl INSTANCE = null;

	/** Point d'acc�s pour l'instance unique du singleton */
	public static VerifFishDAO getInstance() {
		if (INSTANCE == null) {
			INSTANCE = new VerifFishDAOImpl();
		}
		return INSTANCE;
	}

	@Override
	public List<VerifFish> getVerifFishByIdAlteration(int idAlt) {
		List<VerifFish> vb = new ArrayList<VerifFish>();
		try {
			String sql = "SELECT v FROM VerifFish v WHERE v.alteration.idAlteration = :idAlteration";
			Query query = HibernateUtil.getSession().createQuery(sql).setParameter("idAlteration", idAlt);
			vb = findMany(query);
		} catch (ObjectNotFoundException ex) {
			vb = new ArrayList<VerifFish>();
		}
		return vb;
	}

	@Override
	public List<VerifFish> getVerifFishByRenduFish(int idRenduFish) {
		List<VerifFish> vf = new ArrayList<VerifFish>();
		try {
			String sql = "SELECT v FROM VerifFish v WHERE v.renduFish.idRenduFish = :idRenduFish";
			Query query = HibernateUtil.getSession().createQuery(sql).setParameter("idRenduFish", idRenduFish);
			vf = findMany(query);
		} catch (ObjectNotFoundException ex) {
			vf = new ArrayList<VerifFish>();
		}
		return vf;
	}
}